//
//  Distric.m
//  Province-City-zone
//
//  Created by dllo on 16/7/11.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "Distric.h"

@implementation Distric
- (instancetype)initWithName:(NSString *)name {
    // 在实例方法中,self 代表实例对象(调用者)
    
    return [self initWithName:name number:nil];
}
+ (instancetype)districtWithName:(NSString *)name {
    // 在类方法中 ,self 代表类对象本身
    return [[self alloc] initWithName:name];
}
// 重写打印
- (NSString *)description {
    return [NSString stringWithFormat:@"%@",_name];
}
// 再有添加 指派初始化(之前全部的初始化方法需要改动)
- (instancetype)initWithName:(NSString *)name
                      number:(NSString *)number {
    if (self = [super init]) {
        _name = name;
        _number = number;
    }
    return self;
}
+ (instancetype)districtWithName:(NSString *)name
                          number:(NSString *)number {
    return [[Distric alloc] initWithName:name number:number];
}
- (instancetype)initWithTimeCity:(TimeCity *)timeCity {
    return [self initWithName:timeCity.name number:timeCity.cityNumber];
}

+ (instancetype)districWithTimeCity:(TimeCity *)timeCity {
     return [[self alloc] initWithTimeCity:timeCity];
}
@end

